package cn.netswap.jeegorilla.framework.intercepter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by lai_gw on 2020/3/16.
 */
public class GorillaIntercepter implements HandlerInterceptor {

    Logger log = LoggerFactory.getLogger(GorillaIntercepter.class);

    /**
     *进入controller方法之前
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        log.info("preHandle进入controller方法之前......");
        return HandlerInterceptor.super.preHandle(request,response,handler);
    }

    /**
     * 调用完controller之后，视图渲染之前
     * @param request
     * @param response
     * @param handler
     * @param modelAndView
     * @throws Exception
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//        log.info("postHandle调用完controller之后，视图渲染之前......");
    }

    /**
     * 整个完成之后，通常用于资源清理
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//        log.info("afterCompletion整个完成之后，通常用于资源清理......");
    }
}
